package wikiPhilia_two;

import java.util.ArrayList;
import java.util.HashMap;

import processing.core.PApplet;
import processing.core.PFont;
import processing.core.PImage;
import processing.core.PShape;
import processing.core.PVector;

public class WikiPhilia_two_006d extends PApplet {
	public HashMap<String, WNode> allNodes = new HashMap<String, WNode>();
	public ArrayList<WNode> allNodesList = new ArrayList<WNode>();
	public ArrayList<WNode> nodesLevelZeroList = new ArrayList<WNode>();
	public HashMap<String, WNode> nodesLevelZero = new HashMap<String, WNode>();
	public ArrayList<WNode> nodesLevelOneList = new ArrayList<WNode>();
	public HashMap<String, WNode> nodesLevelOne = new HashMap<String, WNode>();
	public ArrayList<WNode> nodesLevelTwoList = new ArrayList<WNode>();
	public HashMap<String, WNode> nodesLevelTwo = new HashMap<String, WNode>();
	public ArrayList<WEdge> allEdgesList = new ArrayList<WEdge>();
	TsvTableHuge inputTable;
	String personZeroTitle = "Coby_Miller";
	// String inputFileName = "Albert_Einstein_complete_stuff.tsv";
	String inputFileName;
	float minRadiusZero = 100f, maxRadiusZero = 200f, minRadiusOne = 400f,
			maxRadiusOne = 200f;
	static float yAngle;
	static float xAngle;
	int loadSize = 500;
	float interval = 0.5f * 30f; // in 30 fps
	int currentRow = 1;
	int maxLinksCount[] = new int[4];
	int maxBacklinksCount[] = new int[4];
	PFont myFont;
	float xOff, yOff, zOff;
	boolean linear = false;
	//von Pierre
	public static PImage myBg, nebel, planet, network;
	public static PShape svg;
	String dataRoot = "E:\\projects\\eclipse_projects\\wikiphilia\\src\\data\\";
//	private PImage myPlanet; 
//	private PImage network; 
//	private PShape svg; 
	static boolean hideEdges = false;
	String dataPath = "E:\\projects\\eclipse_projects\\wikiphilia_TSV_sicherung\\";
	float impLow = 0.75f;
	float impHigh = 1.0f;
	boolean loadData = false;
	boolean planePos = false;
	boolean circularPos;
	boolean record = false;
	
	public void setup() {
		size(1200,1200,P3D);
		myBg = this.loadImage (dataRoot + "bg_2000.jpg");
		nebel = this.loadImage (dataRoot + "nebel.png");
		planet = this.loadImage(dataRoot + "particle.png"); 
		svg = this.loadShape(dataRoot + "cat4_black.svg");
		network = this.loadImage(dataRoot + "network4.png"); 
		inputTable = new TsvTableHuge(this, dataPath + "Coby_Miller_complete_stuff.tsv");
		putNode(new WNode(this, personZeroTitle), 0);
		nodesLevelZeroList.get(0).setType(WNode.TYPE_PERSON_ZERO);
		nodesLevelZeroList.get(0).setPos(new PVector(0, 0, 0));
		System.out.println("The table " + inputFileName + " has "
				+ inputTable.getRowCount() + " rows.");
		// System.out.println("The table " + inputFileName + " has "
		// + inputTable.getRowToStringArray(0).length + " coloumns.");
		this.noFill();
		this.noStroke();
		myFont = this.loadFont("data\\TheSerifSemiBold-Plain-48.vlw");
		this.textFont(myFont, 9);
		this.textAlign(this.CENTER);
		this.textMode(this.MODEL);
		xOff = 0;
		yOff = 0;
		for (int i = 0; i < maxLinksCount.length; i++) {
			maxLinksCount[i] = -1;
			maxBacklinksCount[i] = -1;
		}
		frameRate(30);
	}

	public void draw() {
		this.background(0);
		this.pushMatrix();
		this.translate(0,0,-900);
		this.beginShape();
		this.texture(myBg); 
		this.vertex((this.width-myBg.width)/2, (this.width-myBg.width)/2, 0,0);
		this.vertex(this.width-((this.width-myBg.width)/2),(this.width-myBg.width)/2, 0, 0, myBg.width);
		this.vertex(this.width-((this.width-myBg.width)/2),this.width-((this.width-myBg.width)/2) , myBg.width, myBg.width);
		this.vertex((this.width-myBg.width)/2, this.width-((this.width-myBg.width)/2), 0, 0, myBg.width);
		//rect(0,0,400, 400); 
		this.endShape();
		this.popMatrix();
		
		
		this.translate(xOff, yOff, zOff);
		this.translate(this.width / 2, this.height / 2);
		xAngle = this.map(this.mouseY, 0, this.height, 0, this.TWO_PI);
		yAngle = this.map(this.mouseX, 0, this.width, 0, this.TWO_PI) + this.PI;
		this.rotateX(xAngle);
		this.rotateY(yAngle);
		this.beginShape();
		//	textureMode(NORMALIZED);
			//tint(0,20,20,255); 
 

		//if (this.frameCount % interval == 0) {
		if (loadData) {
			loadData = false;
			addNodesEdges(inputTable, currentRow, currentRow + loadSize - 1);
			currentRow = this.min((currentRow + loadSize),
					inputTable.getRowCount());
			  if (circularPos) {
					setCircularPositions(nodesLevelOneList, nodesLevelZeroList.get(0),
							minRadiusZero, maxRadiusZero, 41, 43);
					setCircularPositions(nodesLevelTwoList, nodesLevelZeroList.get(0),
							minRadiusZero, maxRadiusZero, 43, 41);

			  } else {
				setSphericalPositions(nodesLevelOneList, nodesLevelZeroList.get(0),
						minRadiusZero, maxRadiusZero, 41, 43);
				setSphericalPositions(nodesLevelTwoList, nodesLevelZeroList.get(0),
						minRadiusZero, maxRadiusZero, 43, 41);	
			  }
			
			 setImportanceHighlights(nodesLevelZeroList.get(0), impLow, impHigh);
			 

		}
		for (int i = 0; i < allNodesList.size(); i++) {
			allNodesList.get(i).update();
			allNodesList.get(i).display();
		}
		for (int i = 0; i < nodesLevelOneList.size(); i++) {
			nodesLevelOneList.get(i).display();
		}
		for (int i = 0; i < nodesLevelTwoList.size(); i++) {
			nodesLevelTwoList.get(i).display();
		}
		for (int i = 0; i < allEdgesList.size(); i++) {
			allEdgesList.get(i).display();
		}
		if (record) {
			saveFrame("D:\\RENDERS\\wikiphilia\\wp_render_001\\wp_render-#####.jpg");
		}
	}

	public void setCircularPositions(ArrayList<WNode> theNodes, WNode origin,
			float minR, float maxR, int hC, int vC) {
		int nodeCount = theNodes.size();
		float myInc = 1 / (float) (nodeCount);
		// centerNode.setPos(new PVector(0,0,0));
		float hCycles = hC;
		float vCycles = vC;
		int originIndex;
		if (theNodes.contains(origin)) {
			originIndex = theNodes.indexOf(origin);
		} else {
			originIndex = -1;
		}
		for (int i = 0; i < nodeCount; i++) {
			if (i != originIndex) {
				float myRadius = minR
						+ (theNodes.get(i).getLinksCount(3) / (float) maxLinksCount[3])
						* (maxR - minR);
				// float myRadius = maxR; ///just for testing purposes!
				float myIncH = myInc * i;
				float myIncV = myInc * i;
				float lambda = this.TWO_PI * myInc * i * hCycles;
				float beta = this.TWO_PI * myInc * i * vCycles;
				float x = origin.getcPos().x + this.sin(lambda) 
						* myRadius;
				float y = origin.getcPos().y ;
				float z = origin.getcPos().z + this.cos(lambda) 
						* myRadius;
				theNodes.get(i).setPos(new PVector(x, y, z));
			}
		}

	}
	
	
	public void setSphericalPositions(ArrayList<WNode> theNodes, WNode origin,
			float minR, float maxR, int hC, int vC) {
		int nodeCount = theNodes.size();
		float myInc = 1 / (float) (nodeCount);
		// centerNode.setPos(new PVector(0,0,0));
		float hCycles = hC;
		float vCycles = vC;
		int originIndex;
		if (theNodes.contains(origin)) {
			originIndex = theNodes.indexOf(origin);
		} else {
			originIndex = -1;
		}
		for (int i = 0; i < nodeCount; i++) {
			if (i != originIndex) {
				float myRadius = minR
						+ (theNodes.get(i).getLinksCount(3) / (float) maxLinksCount[3])
						* (maxR - minR);
				// float myRadius = maxR; ///just for testing purposes!
				float myIncH = myInc * i;
				float myIncV = myInc * i;
				float lambda = this.TWO_PI * myInc * i * hCycles;
				float beta = this.TWO_PI * myInc * i * vCycles;
				float x = origin.getcPos().x + this.sin(lambda) * this.cos(beta)
						* myRadius;
				float y = origin.getcPos().y + this.sin(beta) * myRadius;
				float z = origin.getcPos().z + this.cos(lambda) * this.cos(beta)
						* myRadius;
				theNodes.get(i).setPos(new PVector(x, y, z));
			}
		}

	}
	public void setLinearPositions(ArrayList<WNode> theNodes, WNode origin,
			float w, float minH, float maxH) {
		int nodeCount = theNodes.size();
		float myInc = 1 / (float) (nodeCount);
		// centerNode.setPos(new PVector(0,0,0));
		int originIndex;
		if (theNodes.contains(origin)) {
			originIndex = theNodes.indexOf(origin);
		} else {
			originIndex = -1;
		}
		for (int i = 0; i < nodeCount; i++) {
			if (i != originIndex) {
				float myHeight = minH
				+ (theNodes.get(i).getLinksCount(3) / (float) maxLinksCount[3])
				* (maxH - minH);
				// float myRadius = maxR; ///just for testing purposes!
				float x = origin.getcPos().x + -w/2+myInc*i*w;
				float y = origin.getcPos().y + myHeight;
				float z = origin.getcPos().z ;
				theNodes.get(i).setPos(new PVector(x, y, z));
			}
		}
		
	}

	public void addNodesEdges(TsvTableHuge sourceTable, int startIndex,
			int endIndex) {
		for (int i = this.min(sourceTable.getRowCount(), startIndex); i < this.min(
				sourceTable.getRowCount(), endIndex); i++) {
			String fromTitle = inputTable.getString(i, 0);
			String toTitle = inputTable.getString(i, 1);
			String fromType = inputTable.getString(i, 2);
			String toType = inputTable.getString(i, 3);
			int iFromType = WNode.TYPE_ARTICLE;
			int iToType = WNode.TYPE_ARTICLE;
			if (fromType.equalsIgnoreCase("person"))
				iFromType = WNode.TYPE_PERSON;
			if (fromType.equalsIgnoreCase("non_person"))
				iFromType = WNode.TYPE_NON_PERSON;
			if (fromType.equalsIgnoreCase("category"))
				iFromType = WNode.TYPE_CATEGORY;
			if (toType.equalsIgnoreCase("person"))
				iToType = WNode.TYPE_PERSON;
			if (toType.equalsIgnoreCase("non_person"))
				iToType = WNode.TYPE_NON_PERSON;
			if (toType.equalsIgnoreCase("category"))
				iToType = WNode.TYPE_CATEGORY;
			WNode fromNode = new WNode(this, fromTitle, iFromType);
			WNode toNode = new WNode(this, toTitle, iToType);
			// TODO: loops!!!!
			int myCaseFrom = 5;
			int myCaseTo = 5;
			int myCase;// /// is a product of the abovementioned
			if (nodesLevelZero.containsKey(fromTitle))
				myCaseFrom = 1;
			if (nodesLevelOne.containsKey(fromTitle))
				myCaseFrom = 2;
			if (nodesLevelTwo.containsKey(fromTitle))
				myCaseFrom = 3;
			if (nodesLevelZero.containsKey(toTitle))
				myCaseTo = 1;
			if (nodesLevelOne.containsKey(toTitle))
				myCaseTo = 2;
			if (nodesLevelTwo.containsKey(toTitle))
				myCaseTo = 3;
			myCase = myCaseFrom * myCaseTo;
			int type = WEdge.TYPE_UNDEF;
			switch (myCase) {
			case 1: // /nonsense
				System.out.println("ERROR IN ALGORYTHM!");
				break;
			case 2: // / 0 <-> 1 check for loop?
				if (nodesLevelZero.containsKey(fromTitle)) {
					nodesLevelZero.get(fromTitle).incLinks(1);
					nodesLevelOne.get(toTitle).incBacklinks(0);
					if (checkLoop(fromNode, toNode)) {
						type = WEdge.TYPE_LOOP;
					}
					allEdgesList.add(new WEdge(this, fromNode, toNode, type));
				} else {
					nodesLevelOne.get(fromTitle).incLinks(0);
					nodesLevelZero.get(toTitle).incBacklinks(1);
					if (checkLoop(fromNode, toNode)) {
						type = WEdge.TYPE_LOOP;
						allEdgesList.add(new WEdge(this, fromNode, toNode, type));
					}
				}
				break;
			case 3: // / 0 <-> 3; nonsense
				System.out.println("ERROR IN ALGORYTHM!");
				break;
			case 4: // / 1 <-> 1: check for loop?
				nodesLevelOne.get(fromTitle).incLinks(1);
				nodesLevelOne.get(toTitle).incBacklinks(1);
				if (checkLoop(fromNode, toNode)) {
					type = WEdge.TYPE_LOOP;
					allEdgesList.add(new WEdge(this, fromNode, toNode, type));
				}
				break;
			case 5: // / 0 <->NA => 0-1n
				if (nodesLevelZero.containsKey(fromTitle)) {
					putNode(toNode, 1);
					nodesLevelZero.get(fromTitle).incLinks(1);
					toNode.incBacklinks(0);
					allEdgesList.add(new WEdge(this, nodesLevelZero
							.get(fromTitle), toNode));
					type = WEdge.TYPE_UNDEF;
					if (checkLoop(fromNode, toNode)) {
						type = WEdge.TYPE_LOOP;
						allEdgesList.add(new WEdge(this, fromNode, toNode, type));
					}
				} else {
					putNode(fromNode, 1);
					nodesLevelZero.get(toTitle).incBacklinks(1);
					toNode.incLinks(1);
					allEdgesList.add(new WEdge(this, fromNode, nodesLevelZero
							.get(toTitle)));
				}
				break;
			case 6: // / 1 <-> 2: check for loop?
				if (nodesLevelOne.containsKey(fromTitle)) {
					nodesLevelOne.get(fromTitle).incLinks(2);
					nodesLevelTwo.get(toTitle).incBacklinks(1);
					type = WEdge.TYPE_UNDEF;
					if (checkLoop(fromNode, toNode)) {
						type = WEdge.TYPE_LOOP;
						allEdgesList.add(new WEdge(this, fromNode, toNode, type));
					} else {
						// nodesLevelTwo.get(fromTitle).incLinks(1);
						// nodesLevelOne.get(toTitle).incBacklinks(2);
						allEdgesList.add(new WEdge(this, fromNode, toNode));
						type = WEdge.TYPE_UNDEF;
						if (checkLoop(fromNode, toNode)) {
							type = WEdge.TYPE_LOOP;
							allEdgesList.add(new WEdge(this, fromNode, toNode,
									type));
						}
					}
				}
				break;
			case 9: // / 2 <-> 2: check for loop?
				nodesLevelTwo.get(fromTitle).incLinks(2);
				nodesLevelTwo.get(toTitle).incBacklinks(2);
				allEdgesList.add(new WEdge(this, fromNode, toNode));
				if (checkLoop(fromNode, toNode)) {
					type = WEdge.TYPE_LOOP;
					allEdgesList.add(new WEdge(this, fromNode, toNode, type));
				}
				break;
			case 10: // / 1 <-> NA => 1-2n
				if (nodesLevelOne.containsKey(fromTitle)) {
					putNode(toNode, 2);
					nodesLevelOne.get(fromTitle).incLinks(2);
					toNode.incBacklinks(1);
					allEdgesList.add(new WEdge(this,
							nodesLevelOne.get(fromTitle), toNode));
				} else {
					putNode(fromNode, 2);
					nodesLevelOne.get(toTitle).incBacklinks(2);
					fromNode.incLinks(1);
					allEdgesList.add(new WEdge(this, fromNode, nodesLevelOne
							.get(toTitle)));
				}
				break;
			case 15: // / 2 <-> NA => 2-2n
				if (nodesLevelTwo.containsKey(fromTitle)) {
					putNode(toNode, 2);
					nodesLevelTwo.get(fromTitle).incLinks(2);
					toNode.incBacklinks(2);
					allEdgesList.add(new WEdge(this,
							nodesLevelTwo.get(fromTitle), toNode));
				} else {
					putNode(fromNode, 2);
					nodesLevelTwo.get(toTitle).incBacklinks(2);
					fromNode.incLinks(2);
					allEdgesList.add(new WEdge(this, fromNode, nodesLevelTwo
							.get(toTitle)));
				}
				break;
			case 25: // / NA <-> NA => 2n-2n
				putNode(fromNode, 2);
				putNode(toNode, 2);
				fromNode.incLinks(2);
				toNode.incBacklinks(2);
				allEdgesList.add(new WEdge(this, fromNode, toNode));
				break;

			default:
				break;
			}
		}
		// ////LOOP handling!!!
		for (int i = 0; i < allNodesList.size(); i++) {
			for (int j = 0; j < 4; j++) {
				if (maxLinksCount[j] < allNodesList.get(i).getLinksCount(j)) {
					maxLinksCount[j] = allNodesList.get(i).getLinksCount(j);
				}
				;
				if (maxBacklinksCount[j] < allNodesList.get(i)
						.getBacklinksCount(j)) {
					maxBacklinksCount[j] = allNodesList.get(i)
							.getBacklinksCount(j);
				}
				;
			}
		}
	}

	public boolean checkLoop(WNode fromNode, WNode toNode) {
		for (int i = 0; i < allEdgesList.size(); i++) {
			if (allEdgesList.get(i).getToNode().equals(fromNode)
					&& allEdgesList.get(i).getFromNode().equals(toNode)) {
				return true;
			}
		}
		return false;
	}

	public void putNode(WNode theNode, int level) {
		switch (level) {
		case 0:
			nodesLevelZero.put(theNode.getTitle(), theNode);
			nodesLevelZeroList.add(theNode);
			allNodes.put(theNode.getTitle(), theNode);
			allNodesList.add(theNode);
			theNode.setLevel(WNode.LEVEL_ZERO);
			break;
		case 1:
			nodesLevelOne.put(theNode.getTitle(), theNode);
			nodesLevelOneList.add(theNode);
			allNodes.put(theNode.getTitle(), theNode);
			allNodesList.add(theNode);
			theNode.setLevel(WNode.LEVEL_ONE);
			break;
		case 2:
			nodesLevelTwo.put(theNode.getTitle(), theNode);
			nodesLevelTwoList.add(theNode);
			allNodes.put(theNode.getTitle(), theNode);
			allNodesList.add(theNode);
			theNode.setLevel(WNode.LEVEL_TWO);
			break;

		default:
			break;
		}
	};

	public void setImportanceHighlights(WNode theNode, float thresholdLow, float thresholdHigh) {
		for (int i = 0; i < allNodesList.size(); i++) {
			allNodesList.get(i).setState(WNode.STATE_DEFAULT);
		
		}
		for (int i = 0; i < allEdgesList.size(); i++) {
			allEdgesList.get(i).setState(WNode.STATE_DEFAULT);
		}
		for (int i = 0; i < allEdgesList.size(); i++) {
			if (allEdgesList.get(i).getFromNode().equals(theNode) && 
					((allEdgesList.get(i).getToNode().getLinksCount(3) >= maxLinksCount[3]*thresholdLow
					&& 		allEdgesList.get(i).getToNode().getLinksCount(3) <= maxLinksCount[3]*thresholdHigh
					) || (allEdgesList.get(i).getToNode().getBacklinksCount(3) >= maxBacklinksCount[3]*thresholdLow
					&& 		allEdgesList.get(i).getToNode().getBacklinksCount(3) <= maxBacklinksCount[3]*thresholdHigh
					))) {
				allEdgesList.get(i).getFromNode().setState(WNode.STATE_HIGHLIGHTED);
				allEdgesList.get(i).getToNode().setState(WNode.STATE_HIGHLIGHTED);
				allEdgesList.get(i).setState(WEdge.STATE_HIGHLIGHTED);
			}

			if (allEdgesList.get(i).getToNode().equals(theNode) && 
					((allEdgesList.get(i).getFromNode().getLinksCount(3) >= maxLinksCount[3]*thresholdLow
					&& 		allEdgesList.get(i).getFromNode().getLinksCount(3) <= maxLinksCount[3]*thresholdHigh
					) || (allEdgesList.get(i).getFromNode().getBacklinksCount(3) >= maxBacklinksCount[3]*thresholdLow
					&& 		allEdgesList.get(i).getFromNode().getBacklinksCount(3) <= maxBacklinksCount[3]*thresholdHigh
					))) {
				allEdgesList.get(i).getFromNode().setState(WNode.STATE_HIGHLIGHTED);
				allEdgesList.get(i).getToNode().setState(WNode.STATE_HIGHLIGHTED);
				allEdgesList.get(i).setState(WEdge.STATE_HIGHLIGHTED);
			}

					
					//|| allEdgesList.get(i).getToNode().equals(theNode)) {
				
			}
		}
	
	
	
	

	public void keyPressed() {
		  if (this.key == ' ') loadData = true;
		  if (this.key == 'y') {
			planePos  = !planePos;
			if (planePos) {
				setLinearPositions(nodesLevelOneList, nodesLevelZeroList.get(0), 
						maxRadiusZero, minRadiusZero, maxRadiusZero);
				setLinearPositions(nodesLevelTwoList, nodesLevelZeroList.get(0),
						maxRadiusZero, minRadiusZero, maxRadiusZero);
			} else {
				setSphericalPositions(nodesLevelOneList, nodesLevelZeroList.get(0),
						minRadiusZero, maxRadiusZero, 41, 43);
				setSphericalPositions(nodesLevelTwoList, nodesLevelZeroList.get(0),
						minRadiusZero, maxRadiusZero, 43, 41);
			}
		  }
		  if (this.key == 'q') {
				circularPos  = !circularPos;
				if (circularPos) {
					setCircularPositions(nodesLevelOneList, nodesLevelZeroList.get(0),
							minRadiusZero, maxRadiusZero, 41, 43);
					setCircularPositions(nodesLevelTwoList, nodesLevelZeroList.get(0),
							minRadiusZero, maxRadiusZero, 43, 41);

				} else {
					setSphericalPositions(nodesLevelOneList, nodesLevelZeroList.get(0),
							minRadiusZero, maxRadiusZero, 41, 43);
					setSphericalPositions(nodesLevelTwoList, nodesLevelZeroList.get(0),
							minRadiusZero, maxRadiusZero, 43, 41);
				}
			  }
		  if (this.key == 'w') yOff -= 5;
		  if (this.key == 's') yOff += 5;
		  if (this.key == 'a') xOff -= 5;
		  if (this.key == 'd') xOff += 5;
		  if (this.key == 'e') zOff += 5;
		  if (this.key == 'c') zOff -= 5;
		  if (this.key == 'v') record = !record;
		  if (this.key == 'r') {
			  maxRadiusZero += 10;
			  if (circularPos) {
					setCircularPositions(nodesLevelOneList, nodesLevelZeroList.get(0),
							minRadiusZero, maxRadiusZero, 41, 43);
					setCircularPositions(nodesLevelTwoList, nodesLevelZeroList.get(0),
							minRadiusZero, maxRadiusZero, 43, 41);

			  } else {
				setSphericalPositions(nodesLevelOneList, nodesLevelZeroList.get(0),
						minRadiusZero, maxRadiusZero, 41, 43);
				setSphericalPositions(nodesLevelTwoList, nodesLevelZeroList.get(0),
						minRadiusZero, minRadiusZero, 43, 41);	
			  }
				System.out.println("min. radius: " + minRadiusZero);
				System.out.println("max. radius: " + maxRadiusZero);
		  }
		  if (this.key == 'f') {
			  maxRadiusZero -= 10;
			  if (maxRadiusZero < 0) maxRadiusZero = 0;
			  if (circularPos) {
					setCircularPositions(nodesLevelOneList, nodesLevelZeroList.get(0),
							minRadiusZero, maxRadiusZero, 41, 43);
					setCircularPositions(nodesLevelTwoList, nodesLevelZeroList.get(0),
							minRadiusZero, maxRadiusZero, 43, 41);

			  } else {
				setSphericalPositions(nodesLevelOneList, nodesLevelZeroList.get(0),
						minRadiusZero, maxRadiusZero, 41, 43);
				setSphericalPositions(nodesLevelTwoList, nodesLevelZeroList.get(0),
						minRadiusZero, minRadiusZero, 43, 41);	
			  }
				System.out.println("min. radius: " + minRadiusZero);
				System.out.println("max. radius: " + maxRadiusZero);
		  }
		  
		  if (this.key == 't') {
			  minRadiusZero += 10;
			  if (circularPos) {
					setCircularPositions(nodesLevelOneList, nodesLevelZeroList.get(0),
							minRadiusZero, maxRadiusZero, 41, 43);
					setCircularPositions(nodesLevelTwoList, nodesLevelZeroList.get(0),
							minRadiusZero, maxRadiusZero, 43, 41);

			  } else {
				setSphericalPositions(nodesLevelOneList, nodesLevelZeroList.get(0),
						minRadiusZero, maxRadiusZero, 41, 43);
				setSphericalPositions(nodesLevelTwoList, nodesLevelZeroList.get(0),
						minRadiusZero, minRadiusZero, 43, 41);	
			  }
				System.out.println("min. radius: " + minRadiusZero);
				System.out.println("max. radius: " + maxRadiusZero);

		  }
		  
		  if (this.key == 'g') {
			  minRadiusZero -= 10;
			  
			  if (minRadiusZero < 0) minRadiusZero = 0;
			  if (circularPos) {
					setCircularPositions(nodesLevelOneList, nodesLevelZeroList.get(0),
							minRadiusZero, maxRadiusZero, 41, 43);
					setCircularPositions(nodesLevelTwoList, nodesLevelZeroList.get(0),
							minRadiusZero, maxRadiusZero, 43, 41);

			  } else {
				setSphericalPositions(nodesLevelOneList, nodesLevelZeroList.get(0),
						minRadiusZero, maxRadiusZero, 41, 43);
				setSphericalPositions(nodesLevelTwoList, nodesLevelZeroList.get(0),
						minRadiusZero, minRadiusZero, 43, 41);	
			  }
				System.out.println("min. radius: " + minRadiusZero);
				System.out.println("max. radius: " + maxRadiusZero);
		  }
		  if (this.key == 'u') {
			  impLow += 0.01f;
			  System.out.println("imp low: " + impLow);
			  System.out.println("imp high: " + impHigh);
				 setImportanceHighlights(nodesLevelZeroList.get(0), impLow, impHigh);
		  }
		  if (this.key == 'j') {
			  impLow -= 0.01f;
			  System.out.println("imp low: " + impLow);
			  System.out.println("imp high: " + impHigh);
				 setImportanceHighlights(nodesLevelZeroList.get(0), impLow, impHigh);

		  }
		  if (this.key == 'i') {
			  impHigh += 0.01f;
			  System.out.println("imp low: " + impLow);
			  System.out.println("imp high: " + impHigh);
				 setImportanceHighlights(nodesLevelZeroList.get(0), impLow, impHigh);

		  }
		  if (this.key == 'k') {
			  impHigh -= 0.01f;
			  System.out.println("imp low: " + impLow);
			  System.out.println("imp high: " + impHigh);
				 setImportanceHighlights(nodesLevelZeroList.get(0), impLow, impHigh);

		  }
		  
		  
//		  if (this.key == 'y') {
//		    simpleSetup = !simpleSetup;
//		    setupChanged = true;
//		  }
//		  if (this.key == 'q') {
//		    simpleSetup = !simpleSetup;
//		    setupChanged = true;
//		  }
		  if (this.key == 'h') {
			  hideEdges = !hideEdges;
		  }
		}
	
}
